/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id$ 
#
# $Author$ 
#
# $Revision$ 
#
# $Date$ 
#
# Description: 
#
=============================================================================*/
#include "rtos-wsn.h"
#include "test-blink-bind.h"

static uint16  blink_state = 0;
static struct wsn_timer blink_test_timer;

CONTROL_OUT_OUT(void, on)(uint16);
CONTROL_OUT_OUT(void, off)(uint16);

void blink_test_timer_func(struct wsn_timer *timer)
{
	blink_state = ~blink_state;
	if(blink_state)
		CONTROL_OUT(on)(0x04);//CONTROL_BLINK_TOGGLEon
	else
		CONTROL_OUT(off)(0x04);//CONTROL_BLINK_TOGGLEoff	

	WSN_StartTimer(&blink_test_timer, CONSTAINT_MINI_TO_TICKS(200) );
}


void CONTROL_IN_IN(init)(uint8 mode, uint8 flags)//CONTROL_BLINKTEST_INinit
{
	WSN_InitTimer(&blink_test_timer, blink_test_timer_func);	
}

void CONTROL_IN_IN(start)(uint8 flags)//CONTROL_BLINKTEST_INstart
{
	WSN_StartTimer(&blink_test_timer, CONSTAINT_MINI_TO_TICKS(1000) );
	WSN_DebugOut("Blink test Start ... ...Red LED Shining.. \n\r");
}


void CONTROL_IN_IN(stop)(uint8 flags)//CONTROL_BLINKTEST_INstop
{
	WSN_StopTimer(&blink_test_timer);
	WSN_DebugOut("Blink test Stop ... ...\n\r");
}
